/*
 * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
 * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 */

/*
 * @(#)DriverManagerConnection.java	1.12 02/01/12
 */

package jdbcts.common;

import com.sun.cts.util.*;
import com.sun.cts.harness.*;
import java.sql.*;
import java.util.*;

import jdbcts.SuperTest;

public class DriverManagerConnection extends SuperTest 
implements JDBCTestConnectionManager {

  public Connection getConnection(Properties p) throws ClassNotFoundException, SQLException, Exception{
    Connection con = null;
//    String dbName, dbUser, dbPassword, dbDriver;
//    dbName = dbUser = dbPassword = dbDriver = null;
    String dbName, dbDriver = null;

//    dbName = p.getProperty("db1","");
    dbName = SuperTest.dbUrl;
//    dbUser = p.getProperty("user1","");
//    dbPassword = p.getProperty("password1","");
//    dbDriver = p.getProperty("Driver","");
    dbDriver = SuperTest.Driver;

//    TestUtil.logTrace("Database1 : " + dbName);
//    TestUtil.logTrace("Username  : " + dbUser);
//    TestUtil.logTrace("Password  : " + dbPassword);
    TestUtil.logTrace("Driver    : " + dbDriver);

    TestUtil.logTrace("About to load the driver class");
    Class.forName(dbDriver);
    TestUtil.logMsg("Successfully loaded the driver class");

    TestUtil.logTrace("About to make the DB connection");
//    con=DriverManager.getConnection(dbName, dbUser, dbPassword);
    con = DriverManager.getConnection(dbName);
    TestUtil.logMsg("Made the JDBC connection to the DB");

    return con;
  }

}
